package com.soo.hoo.core.exception;


import com.soo.hoo.core.enums.ResultEnum;

/**
 * <p>
 * 自定义异常
 * </p>
 *
 * @author 杨燚
 * @since 2021-03-01
 */
public class GlobalException extends RuntimeException {

    /**
     * 异常码
     */
    protected Integer code;

    /**
     * 异常信息
     */
    protected String msg;

    public GlobalException(String msg) {
        super(msg);
        this.msg = msg;
        this.code = ResultEnum.FAIL.getCode();
    }

    public GlobalException(Integer code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public GlobalException(ResultEnum result) {
        super(result.getMsg());
        this.code = result.getCode();
        this.msg = result.getMsg();
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public GlobalException(String message, Throwable cause) {
        super(message, cause);
    }

    public GlobalException(Throwable cause) {
        super(cause);
    }
}
